<!DOCTYPE html>
<html lang=zh>
<head>
    <!-- hexo-inject:begin --><!-- hexo-inject:end --><!-- so meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="HandheldFriendly" content="True">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5" />
    <meta name="description" content="朴素贝叶斯是一类很简单的分类算法, 应用场景较多, 如垃圾邮件分类, 输入法中的拼写检查, 文本情感分类等等. 初学朴素贝叶斯时被”朴素”二字迷惑, 认为之所以称之为 “朴素” 时因为算法很 “简单”, 很naive. 实际上, “朴素” 更准确的含义是（特征间的）条件独立性假设, 由于这一假设使得这个算法很 “naive”, 他的引入是为了简化后验概率的计算. 学习算法不能走马观花, 浅尝辄止,">
<meta property="og:type" content="article">
<meta property="og:title" content="机器学习算法: 朴素贝叶斯篇">
<meta property="og:url" content="https://hillbamboo.gitee.io/2019/07/17/naive-bayes/index.html">
<meta property="og:site_name" content="拿铁轮的自留地">
<meta property="og:description" content="朴素贝叶斯是一类很简单的分类算法, 应用场景较多, 如垃圾邮件分类, 输入法中的拼写检查, 文本情感分类等等. 初学朴素贝叶斯时被”朴素”二字迷惑, 认为之所以称之为 “朴素” 时因为算法很 “简单”, 很naive. 实际上, “朴素” 更准确的含义是（特征间的）条件独立性假设, 由于这一假设使得这个算法很 “naive”, 他的引入是为了简化后验概率的计算. 学习算法不能走马观花, 浅尝辄止,">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://hillbamboo.gitee.io/2019/07/17/naive-bayes/bayes-theorem.jpg">
<meta property="og:image" content="https://images.cnblogs.com/cnblogs_com/leoo2sk/WindowsLiveWriter/4f6168bb064a_9C14/1_thumb.png">
<meta property="article:published_time" content="2019-07-17T01:33:40.000Z">
<meta property="article:modified_time" content="2021-05-31T23:57:54.880Z">
<meta property="article:author" content="拿铁轮">
<meta property="article:tag" content="ml, algos">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://hillbamboo.gitee.io/2019/07/17/naive-bayes/bayes-theorem.jpg">
    
    
      
        
          <link rel="shortcut icon" href="/images/favicon.ico">
        
      
      
        
          <link rel="icon" type="image/png" href="/images/favicon-192x192.png" sizes="192x192">
        
      
      
        
          <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
        
      
    
    <!-- title -->
    <title>机器学习算法: 朴素贝叶斯篇</title>
    <!-- styles -->
    
<link rel="stylesheet" href="/css/style.css">

    <!-- persian styles -->
    
    <!-- rss -->
    
    
      <link rel="alternate" href="/true" title="拿铁轮的自留地" type="application/atom+xml" />
    
	<!-- mathjax -->
	
<meta name="generator" content="Hexo 4.2.1"><!-- hexo-inject:begin --><!-- hexo-inject:end --></head>

<body class="max-width mx-auto px3 ltr">
    
      <!-- hexo-inject:begin --><!-- hexo-inject:end --><div id="header-post">
  <a id="menu-icon" href="#" aria-label="目录"><i class="fas fa-bars fa-lg"></i></a>
  <a id="menu-icon-tablet" href="#" aria-label="目录"><i class="fas fa-bars fa-lg"></i></a>
  <a id="top-icon-tablet" href="#" aria-label="顶部" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');" style="display:none;"><i class="fas fa-chevron-up fa-lg"></i></a>
  <span id="menu">
    <span id="nav">
      <ul>
        <!--
       --><li><a href="/">首页</a></li><!--
     --><!--
       --><li><a href="/about/">关于</a></li><!--
     --><!--
       --><li><a href="/archives/">归档</a></li><!--
     --><!--
       --><li><a href="/categories/">分类</a></li><!--
     --><!--
       --><li><a href="/tags/">标签</a></li><!--
     --><!--
       --><li><a href="/search/">搜索</a></li><!--
     -->
      </ul>
    </span>
    <br/>
    <span id="actions">
      <ul>
        
        <li><a class="icon" aria-label="上一篇" href="/2019/07/20/dp-basic/"><i class="fas fa-chevron-left" aria-hidden="true" onmouseover="$('#i-prev').toggle();" onmouseout="$('#i-prev').toggle();"></i></a></li>
        
        
        <li><a class="icon" aria-label="下一篇" href="/2019/06/01/learn-xgb/"><i class="fas fa-chevron-right" aria-hidden="true" onmouseover="$('#i-next').toggle();" onmouseout="$('#i-next').toggle();"></i></a></li>
        
        <li><a class="icon" aria-label="返回顶部" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up" aria-hidden="true" onmouseover="$('#i-top').toggle();" onmouseout="$('#i-top').toggle();"></i></a></li>
        <li><a class="icon" aria-label="分享文章" href="#"><i class="fas fa-share-alt" aria-hidden="true" onmouseover="$('#i-share').toggle();" onmouseout="$('#i-share').toggle();" onclick="$('#share').toggle();return false;"></i></a></li>
      </ul>
      <span id="i-prev" class="info" style="display:none;">上一篇</span>
      <span id="i-next" class="info" style="display:none;">下一篇</span>
      <span id="i-top" class="info" style="display:none;">返回顶部</span>
      <span id="i-share" class="info" style="display:none;">分享文章</span>
    </span>
    <br/>
    <div id="share" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/" target="_blank" rel="noopener"><i class="fab fa-facebook " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&text=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-twitter " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-linkedin " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://service.weibo.com/share/share.php?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-weibo " aria-hidden="true"></i></a></li>
  <!-- <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&is_video=false&description=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-pinterest " aria-hidden="true"></i></a></li> -->
  <li><a class="icon" href="mailto:?subject=机器学习算法: 朴素贝叶斯篇&body=Check out this article: https://hillbamboo.gitee.io/2019/07/17/naive-bayes/"><i class="fas fa-envelope " aria-hidden="true"></i></a></li>
  <!-- <li><a class="icon" href="https://getpocket.com/save?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-get-pocket " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-reddit " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-stumbleupon " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-digg " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&name=机器学习算法: 朴素贝叶斯篇&description=&lt;p&gt;朴素贝叶斯是一类很简单的分类算法, 应用场景较多, 如垃圾邮件分类, 输入法中的拼写检查, 文本情感分类等等. 初学朴素贝叶斯时被”朴素”二字迷惑, 认为之所以称之为 “朴素” 时因为算法很 “简单”, 很naive. 实际上, “朴素” 更准确的含义是（特征间的）条件独立性假设, 由于这一假设使得这个算法很 “naive”, 他的引入是为了简化后验概率的计算. 学习算法不能走马观花, 浅尝辄止, 还是得花时间好好琢磨. &lt;/p&gt;" target="_blank" rel="noopener"><i class="fab fa-tumblr " aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&t=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-hacker-news " aria-hidden="true"></i></a></li> -->
</ul>



    </div>
    <div id="toc">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#贝叶斯公式"><span class="toc-number">1.</span> <span class="toc-text">贝叶斯公式</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#朴素贝叶斯算法"><span class="toc-number">2.</span> <span class="toc-text">朴素贝叶斯算法</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#模型假设"><span class="toc-number">2.1.</span> <span class="toc-text">模型假设</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#算法推导"><span class="toc-number">2.2.</span> <span class="toc-text">算法推导</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#算法流程"><span class="toc-number">2.3.</span> <span class="toc-text">算法流程</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#注意项"><span class="toc-number">2.4.</span> <span class="toc-text">注意项</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#总结"><span class="toc-number">3.</span> <span class="toc-text">总结</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#参考资源"><span class="toc-number">4.</span> <span class="toc-text">参考资源</span></a></li></ol>
    </div>
  </span>
</div>

    
    <div class="content index py4">
        
        <article class="post" itemscope itemtype="http://schema.org/BlogPosting">
  <header>
    
    <h1 class="posttitle" itemprop="name headline">
        机器学习算法: 朴素贝叶斯篇
    </h1>



    <div class="meta">
      <span class="author" itemprop="author" itemscope itemtype="http://schema.org/Person">
        <span itemprop="name">拿铁轮</span>
      </span>
      
    <div class="postdate">
      
        <time datetime="2019-07-17T01:33:40.000Z" itemprop="datePublished">2019-07-17</time>
        
      
    </div>


      

      
    <div class="article-tag">
        <i class="fas fa-tag"></i>
        <a class="tag-link" href="/tags/ml-algos/" rel="tag">ml, algos</a>
    </div>


    </div>
  </header>
  

  <div class="content" itemprop="articleBody">
    <p>朴素贝叶斯是一类很简单的分类算法, 应用场景较多, 如垃圾邮件分类, 输入法中的拼写检查, 文本情感分类等等. 初学朴素贝叶斯时被”朴素”二字迷惑, 认为之所以称之为 “朴素” 时因为算法很 “简单”, 很naive. 实际上, “朴素” 更准确的含义是（特征间的）条件独立性假设, 由于这一假设使得这个算法很 “naive”, 他的引入是为了简化后验概率的计算. 学习算法不能走马观花, 浅尝辄止, 还是得花时间好好琢磨. </p>
<a id="more"></a>
<h1 id="贝叶斯公式"><a href="#贝叶斯公式" class="headerlink" title="贝叶斯公式"></a>贝叶斯公式</h1><p>先补充贝叶斯公式作为预备知识.<br>贝叶斯公式形如下式：<br><img src="bayes-theorem.jpg" alt=""></p>
<p>其中$\mathbb{x}$表示样本, $c$表示类别, 贝叶斯公式给出了样本与类别之间的生成关系.<br>更通俗地讲, 假设给定未知样本$\mathbb{x}$,  $c$的可能取值是 ${0, 1, 2, \cdots,  k}$,  则概率</p>
<script type="math/tex; mode=display">Pr(c=j|\mathbb{x}) = \frac{Pr(\mathbb{x}|c=j) \times Pr(c = j)}{Pr(\mathbb{x})},  \ j=0, 1, \cdots,  k</script><h1 id="朴素贝叶斯算法"><a href="#朴素贝叶斯算法" class="headerlink" title="朴素贝叶斯算法"></a>朴素贝叶斯算法</h1><p>朴素贝叶斯模型是一类生成模型, 它的生成关系有贝叶斯公式给出, 模型的训练是通过最大化后验概率实现的. </p>
<h2 id="模型假设"><a href="#模型假设" class="headerlink" title="模型假设"></a>模型假设</h2><p>朴素贝叶斯算法的前提假设是特征之间的条件独立性, 即：<br>给定样本$\mathbb{x}=(x_1,  x_2,  \cdots,  x_n)$,  其中$x_i$为第$i$个特征, 则</p>
<script type="math/tex; mode=display">Pr(\mathbb{x}|c=j) = Pr(c=j) \times \prod\limits_{i}Pr(x_i|c=j)</script><h2 id="算法推导"><a href="#算法推导" class="headerlink" title="算法推导"></a>算法推导</h2><p>由贝叶斯公式可知</p>
<script type="math/tex; mode=display">Pr(c=j|\mathbb{x}) = \frac{Pr(\mathbb{x}|c=j) \times Pr(c = j)}{Pr(\mathbb{x})},  \ j=0, 1, \cdots,  k</script><p>由于对于同一个样本, $Pr(\mathbb{x})$取值总是相同的, 从而</p>
<script type="math/tex; mode=display">
\begin{aligned}
    j^{*} &=  \mathop{\arg\max}\limits_{j} \frac{Pr(c = j) \times \prod\limits_{i}Pr(x_i|c = j)}{Pr(\mathbb{x})} \\
        & = \mathop{\arg\max}\limits_{j} Pr(c = j) \times \prod\limits_{i}Pr(x_i|c = j)
\end{aligned}</script><p>其中,  $j^{*}$即为样本$\mathbb{x}$的预测类别</p>
<h2 id="算法流程"><a href="#算法流程" class="headerlink" title="算法流程"></a>算法流程</h2><p>朴素贝叶斯算法的训练过程就是一个”计数”过程. 具体来说, 它对训练集统计下列两类概率</p>
<ul>
<li>先验概率（类概率）<br> <script type="math/tex">Pr(c = j) = \frac{\left| D_{c=j}\right|}{\left| D\right|}</script>,<br> 其中 $\left| D_{c=j}\right|$ 为数据集中的类别 $j$所占的数目,  $\left| D\right|$为数据集的大小</li>
<li>条件概率（似然）<script type="math/tex; mode=display">
Pr(x_i|c = j) = 
\begin{cases}
  \frac{\left| D_{x_i,  c=j} \right| }{\left| D_{c} \right| },  & 若\ x\ 离散,  \\
  \frac{1}{\sigma \sqrt{2\pi}}\cdot \exp\left( -\frac{\left( x_i - \mu\right)^2}{2\sigma^2}\right),  & 若\ x\ 连续, 
\end{cases}</script>其中$\left| D_{x_i,  c=j} \right|$为类别是$j$且取值为$x_i$的样本数量. $\mu, \sigma$分别是特征$x_i$的均值与方差</li>
</ul>
<p>朴素贝叶斯算法的整体流程如下图所示:</p>
<p><img src="https://images.cnblogs.com/cnblogs_com/leoo2sk/WindowsLiveWriter/4f6168bb064a_9C14/1_thumb.png" alt=""></p>
<h2 id="注意项"><a href="#注意项" class="headerlink" title="注意项"></a>注意项</h2><ul>
<li><p>条件概率连乘积下溢. 若特征数量很多,  则</p>
<script type="math/tex; mode=display">\prod\limits_{i}Pr(x_i|c=j)</script><p>越接近0. 这种现象称为乘法下溢. 为改进之,  可使用对数似然,  即计算</p>
<script type="math/tex; mode=display">LL\left( \mathbb{x}|c= j\right) = \log(Pr(c=j)) + \sum\limits_{i}\log(Pr(x_i|c=j))</script></li>
<li><p>未登录词.  若带预测样本中出现了训练集中从未出现过的特征取值,  则后验概率总为0,  为了克服这一点,  可以引入拉普拉斯平滑,  即计算</p>
<script type="math/tex; mode=display">
\hat {Pr}(c = j) = \frac{\left| D_{c=j}\right| + \lambda}{\left| D\right| + N_j \cdot \lambda} \\

  \hat {Pr}(\mathbb{x}) = \frac{\left| D_{x_i,  c=j} \right|  + \lambda}{\left| D_{c} \right| + N_{i} \cdot \lambda}</script><p>其中,  $N<em>j$为类别$j$的数量,  $N</em>{i}$为特征$x_i$的可能取值数目,  $\lambda$为大于0的常数,  常取值为1</p>
</li>
</ul>
<h1 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h1><ol>
<li><p>朴素贝叶斯算法的主要优点：</p>
<ul>
<li>对小规模的数据表现很好, 能个处理多分类任务, 适合增量式训练, 尤其是数据量超出内存时, 我们可以一批批的去增量训练. </li>
<li>对缺失数据不太敏感, 常用于文本分类</li>
<li>不受特征尺度的影响, 由于训练过程就是计数的过程, 从而无需归一化等操作</li>
</ul>
</li>
<li><p>朴素贝叶斯的主要缺点：</p>
<ul>
<li>需要知道先验概率, 且先验概率很多时候取决于假设, 假设的模型可以有很多种, 因此在某些时候会由于假设的先验模型的原因导致预测效果不佳</li>
<li>由于我们是通过先验和数据来决定后验的概率从而决定分类, 所以分类决策存在一定的错误率</li>
</ul>
</li>
<li><p>使用朴素贝叶斯算法时的注意点：</p>
<ul>
<li>贝叶斯分类器与一般意义上的”贝叶斯学习”不同,  前者是通过最大后验概率进行单点估计,  后者是进行分布估计</li>
<li>没有平滑之前的朴素贝叶斯算法使用的是极大似然估计,  属于频率派,  平滑之后的进行的是贝叶斯估计,  属于贝叶斯学派</li>
<li>使用对数似然和拉普拉斯平滑是两种不错的改进方式</li>
</ul>
</li>
</ol>
<h1 id="参考资源"><a href="#参考资源" class="headerlink" title="参考资源"></a>参考资源</h1><ol>
<li><a href=""><i class="fa fa-book"></i> 周志华, 机器学习</a></li>
<li><a href="https://www.cnblogs.com/pinard/p/6069267.html" target="_blank" rel="noopener"><i class="fa fa-book"></i> 朴素贝叶斯算法原理小结</a></li>
<li><a href="https://www.cnblogs.com/leoo2sk/archive/2010/09/17/naive-bayesian-classifier.html" target="_blank" rel="noopener"><i class="fa fa-book"></i> 算法杂货铺——分类算法之朴素贝叶斯分类(Naive Bayesian classification)</a></li>
</ol>

  </div>
</article>

    <div class="blog-post-comments">
        <div id="disqus_thread">
            <noscript>加载评论需要在浏览器启用 JavaScript 脚本支持。</noscript>
        </div>
    </div>



        
          <div id="footer-post-container">
  <div id="footer-post">

    <div id="nav-footer" style="display: none">
      <ul>
         
          <li><a href="/">首页</a></li>
         
          <li><a href="/about/">关于</a></li>
         
          <li><a href="/archives/">归档</a></li>
         
          <li><a href="/categories/">分类</a></li>
         
          <li><a href="/tags/">标签</a></li>
         
          <li><a href="/search/">搜索</a></li>
        
      </ul>
    </div>

    <div id="toc-footer" style="display: none">
      <ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#贝叶斯公式"><span class="toc-number">1.</span> <span class="toc-text">贝叶斯公式</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#朴素贝叶斯算法"><span class="toc-number">2.</span> <span class="toc-text">朴素贝叶斯算法</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#模型假设"><span class="toc-number">2.1.</span> <span class="toc-text">模型假设</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#算法推导"><span class="toc-number">2.2.</span> <span class="toc-text">算法推导</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#算法流程"><span class="toc-number">2.3.</span> <span class="toc-text">算法流程</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#注意项"><span class="toc-number">2.4.</span> <span class="toc-text">注意项</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#总结"><span class="toc-number">3.</span> <span class="toc-text">总结</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#参考资源"><span class="toc-number">4.</span> <span class="toc-text">参考资源</span></a></li></ol>
    </div>

    <div id="share-footer" style="display: none">
      <ul>
  <li><a class="icon" href="http://www.facebook.com/sharer.php?u=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/" target="_blank" rel="noopener"><i class="fab fa-facebook fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://twitter.com/share?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&text=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-twitter fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.linkedin.com/shareArticle?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-linkedin fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://service.weibo.com/share/share.php?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-weibo fa-lg" aria-hidden="true"></i></a></li>
  <!-- <li><a class="icon" href="https://pinterest.com/pin/create/bookmarklet/?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&is_video=false&description=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-pinterest fa-lg" aria-hidden="true"></i></a></li> -->
  <li><a class="icon" href="mailto:?subject=机器学习算法: 朴素贝叶斯篇&body=Check out this article: https://hillbamboo.gitee.io/2019/07/17/naive-bayes/"><i class="fas fa-envelope fa-lg" aria-hidden="true"></i></a></li>
  <!-- <li><a class="icon" href="https://getpocket.com/save?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-get-pocket fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://reddit.com/submit?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-reddit fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.stumbleupon.com/submit?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-stumbleupon fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://digg.com/submit?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&title=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-digg fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="http://www.tumblr.com/share/link?url=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&name=机器学习算法: 朴素贝叶斯篇&description=&lt;p&gt;朴素贝叶斯是一类很简单的分类算法, 应用场景较多, 如垃圾邮件分类, 输入法中的拼写检查, 文本情感分类等等. 初学朴素贝叶斯时被”朴素”二字迷惑, 认为之所以称之为 “朴素” 时因为算法很 “简单”, 很naive. 实际上, “朴素” 更准确的含义是（特征间的）条件独立性假设, 由于这一假设使得这个算法很 “naive”, 他的引入是为了简化后验概率的计算. 学习算法不能走马观花, 浅尝辄止, 还是得花时间好好琢磨. &lt;/p&gt;" target="_blank" rel="noopener"><i class="fab fa-tumblr fa-lg" aria-hidden="true"></i></a></li>
  <li><a class="icon" href="https://news.ycombinator.com/submitlink?u=https://hillbamboo.gitee.io/2019/07/17/naive-bayes/&t=机器学习算法: 朴素贝叶斯篇" target="_blank" rel="noopener"><i class="fab fa-hacker-news fa-lg" aria-hidden="true"></i></a></li> -->
</ul>



    </div>

    <div id="actions-footer">
        <a id="menu" class="icon" href="#" onclick="$('#nav-footer').toggle();return false;"><i class="fas fa-bars fa-lg" aria-hidden="true"></i> 菜单</a>
        <a id="toc" class="icon" href="#" onclick="$('#toc-footer').toggle();return false;"><i class="fas fa-list fa-lg" aria-hidden="true"></i> 目录</a>
        <a id="share" class="icon" href="#" onclick="$('#share-footer').toggle();return false;"><i class="fas fa-share-alt fa-lg" aria-hidden="true"></i> 分享</a>
        <a id="top" style="display:none" class="icon" href="#" onclick="$('html, body').animate({ scrollTop: 0 }, 'fast');"><i class="fas fa-chevron-up fa-lg" aria-hidden="true"></i> 返回顶部</a>
    </div>

  </div>
</div>

        
        <footer id="footer">
  <div class="footer-left">
    Copyright &copy;
    
    
    2017-2022
    拿铁轮
  </div>
  <div class="footer-right">
    <nav>
      <ul>
        <!--
       --><li><a href="/">首页</a></li><!--
     --><!--
       --><li><a href="/about/">关于</a></li><!--
     --><!--
       --><li><a href="/archives/">归档</a></li><!--
     --><!--
       --><li><a href="/categories/">分类</a></li><!--
     --><!--
       --><li><a href="/tags/">标签</a></li><!--
     --><!--
       --><li><a href="/search/">搜索</a></li><!--
     -->
      </ul>
    </nav>
  </div>
</footer>

    </div>
    <!-- styles -->



  <link rel="preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.2/css/all.min.css" crossorigin="anonymous" onload="this.onload=null;this.rel='stylesheet'"/>


    <!-- jquery -->
 
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" crossorigin="anonymous"></script> 




<!-- clipboard -->

  
    <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.7/clipboard.min.js" crossorigin="anonymous"></script> 
  
  <script type="text/javascript">
  $(function() {
    // copy-btn HTML
    var btn = "<span class=\"btn-copy tooltipped tooltipped-sw\" aria-label=\"复制到粘贴板！\">";
    btn += '<i class="far fa-clone"></i>';
    btn += '</span>'; 
    // mount it!
    $(".highlight table").before(btn);
    var clip = new ClipboardJS('.btn-copy', {
      text: function(trigger) {
        return Array.from(trigger.nextElementSibling.querySelectorAll('.code')).reduce((str,it)=>str+it.innerText+'\n','')
      }
    });
    clip.on('success', function(e) {
      e.trigger.setAttribute('aria-label', "复制成功！");
      e.clearSelection();
    })
  })
  </script>


<script src="/js/main.js"></script>

<!-- search -->

<!-- Google Analytics -->

<!-- Baidu Analytics -->

<!-- Cloudflare Analytics -->

<!-- Umami Analytics -->

<!-- Disqus Comments -->

    <script type="text/javascript">
        var disqus_shortname = 'cactus-1';

        (function(){
            var dsq = document.createElement('script');
            dsq.type = 'text/javascript';
            dsq.async = true;
            dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
            (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
        }());
    </script>

<!-- utterances Comments --><!-- hexo-inject:begin --><!-- Begin: Injected MathJax -->
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({"tex2jax":{"inlineMath":[["$","$"],["\\(","\\)"]],"skipTags":["script","noscript","style","textarea","pre","code"],"processEscapes":true},"TeX":{"equationNumbers":{"autoNumber":"AMS"}}});
</script>

<script type="text/x-mathjax-config">
  MathJax.Hub.Queue(function() {
    var all = MathJax.Hub.getAllJax(), i;
    for(i=0; i < all.length; i += 1) {
      all[i].SourceElement().parentNode.className += ' has-jax';
    }
  });
</script>

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js">
</script>
<!-- End: Injected MathJax -->
<!-- hexo-inject:end -->

</body>
</html>
